<?php

namespace Admin\Controller;


use Think\Controller;

class ConclusionController extends AdminController
{
    public function __construct()
    {
        parent::__construct();
    }

    //  年终总结用户
    public function index()
    {
        $count = D('conclusionuser')->count();
        $Page = new \Think\Page($count, 10);
        $conclusions = D('conclusionuser')->limit($Page->firstRow . ',' . $Page->listRows)->select();
        $show = $Page->show();
        $this->assign('page', $show);
        $this->assign('conclusions', $conclusions);
        $this->display('user');
    }

    public function del()
    {
        $id = I('get.id');
        $res = M('conclusionuser')->delete($id);
        if ($res) {
            $this->success('删除成功', (U('Admin/conclusion/index')));
        } else {
            $this->error('删除失败');
        }
    }

    //年度总结用户
    public function conclusionuseradd()
    {
        if (!IS_POST) {
            $id = I('get.id', 0);
            $conclusionuser = D('conclusionuser')->find($id);
            $this->assign('conclusionuser', $conclusionuser);
            $this->display();
        } else {
            $conclusionModel = D('conclusionuser');
            if ($_POST['conuserid']) {
                $conclusionModel->where('conuserid='.$_POST['conuserid'])->save($_POST);
            } else {
                $conclusionModel->add($_POST);
            }
            $this->success("修改成功", (U('Admin/conclusion/index')));
        }
    }

    //年度总结
    public function conclusionedit()
    {
        if(!IS_POST){
            $id = I('get.id', 0);
            $conclusionuser = D('conclusionuser')->find($id);
            $this->assign('conclusionuser', $conclusionuser);
            $this->display('conclusion');
        }else{
            $data = $_POST;
            $data['note_pic'] = $_POST['pic1'];
            unset($data['pic1']);
            unset($data['conuserid']);
            M('conclusionuser')->where('conuserid='.$_POST['conuserid'])->save($data);
            $this->success("修改成功", (U('Admin/conclusion/index')));
        }
    }
}